<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>布局篇 计算属性</title>
    <script src="https://cdn.jsdelivr.net/npm/vue@2.5.21/dist/vue.js"></script>
</head>
<body>

<div id="vue">
    <p>调用当前时间的方法：{{currentTime1()}}</p>
    <p>当前时间的计算属性：{{currentTime2}}</p>
    <input type="text" v-model="message"/><button @click="destroy()">销毁</button>
</div>

<script type="text/javascript">


    var vm = new Vue({
        el: '#vue',
        data: {
            message: 'Hello Vue'
        },
        beforeCreate(){
            console.log("我是初始化之前")
        },
        created() {
            //钩子  初始化时候加载  页面进来就马上加载的数据
            this.init()
        },
        beforeMount(){
            console.log("Html挂载到Dom上时候执行")
        },
        mounted(){
            console.log("Html挂载到Dom上之后执行")
        },
        beforeUpdate(){

            console.log("数据更新之前执行")
        },
        updated(){

            console.log("数据更新之后执行")
        },
        beforeDestroy(){
            console.log("销毁之前执行")
        },
        destroyed(){
            console.log("销毁之后执行")
        },
        methods: {
            init: function () {
                console.log("我是初始化")
            },
            currentTime1: function () {
                return Date.now();
            },
            destroy:function(){
                this.$destroy();
            }
        },
        computed: {
            currentTime2: function () {
                //console.log(this.message);
                //console.log(Date.now());
                return Date.now();
            }
        }
    });
</script>
</body>
</html>